<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ko" xml:lang="ko">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>네이버 :: Smart Editor 2 &#8482;</title>
<script type="text/javascript" src="/common/js/jquery-1.11.0.js"></script>
<script type="text/javascript" src="/common/js/common.js"></script>
<script type="text/javascript" src="/common/js/serviceCall.js"></script>
<script type="text/javascript" src="/common/js/datepicker/jquery-ui-1.9.2.custom.js"></script>
<script type="text/javascript" src="/common/js/datepicker/datepicker.config.js"></script>
<script type="text/javascript" src="/common/js/editor/js/HuskyEZCreator.js" charset="utf-8"></script>

</head>
<body>
<form action="sample.php" method="post">
	<textarea name="ir1" id="ir2" rows="10" cols="100" style="width:766px; height:412px; display:none;"></textarea>
	<textarea name="contents" id="contents" rows="10" cols="100" style="width:100%; height:412px; min-width:610px; display:none;"></textarea>
	<p>
		<input type="button" id="submitBtn" value="전송" />
		
	</p>
</form>

<script type="text/javascript">

var test = new NormalServiceCaller("SVC0001");

function fn_searchData(){
	$("#contents").val(EDITOR_CALLER.getEditorContentHTML());
	var param = {};
	param.contents = $("#contents").val();
	$("#log").html("");
	test.processSvc(function(data){
		$("#log").html(data);
	}, param);	
}

var oEditors = [];
var option = {
		"elPlaceHolder" : "ir2",
		"textAreaEl" : "contents",
		"serverContents" : '서버에서 온 내용'
};

$(function(){
	$("#submitBtn").click(function(){
		fn_searchData();
	});
	EDITOR_CALLER.init(option);
});

var EDITOR_CALLER = {
		init : function(option){
			window.textAreaEl = option.textAreaEl;
			window.serverContents = option.serverContents;
			window.elPlaceHolder = option.elPlaceHolder;  //에디터 영역 명
			
			this.generateEditor(oEditors);
			
			if(!gfn_isEmpty(window.serverContents)){
				setTimeout(function(){
					EDITOR_CALLER.pasteHTML(window.serverContents);	
				},1000);
			}
		},
		generateEditor : function(oEditors){
			nhn.husky.EZCreator.createInIFrame({
				oAppRef: oEditors,
				elPlaceHolder: window.elPlaceHolder,
				sSkinURI: "/common/js/editor/SmartEditor2Skin.html",	
				htParams : {
					bUseToolbar : true,				// 툴바 사용 여부 (true:사용/ false:사용하지 않음)
					bUseVerticalResizer : true,		// 입력창 크기 조절바 사용 여부 (true:사용/ false:사용하지 않음)
					bUseModeChanger : true,			// 모드 탭(Editor | HTML | TEXT) 사용 여부 (true:사용/ false:사용하지 않음)
					fOnBeforeUnload : function(){
						
					}
				},				
				fCreator: "createSEditor2"
			});
		},
		pasteHTML : function(contents){
			oEditors.getById[window.elPlaceHolder].exec("PASTE_HTML", [window.serverContents]);
		},
		getEditorContentHTML : function(){
			return oEditors.getById[window.elPlaceHolder].getIR();
		}
};

	//		oEditors.getById["ir1"].exec("PASTE_HTML", [sHTML]);
/*
var editorCaller = function(option){
	this.elPlaceHolder = option.elPlaceHolder;  //에디터 영역 명
	window.oEditors = [];
	this.textArea = option.textArea;
	this.serverContents = option.serverContents;
};

editorCaller.prototype.init = function(){
	this.generateEditor();
	if(this.serverContents){
		this.pasteHTML(this.serverContents);
	}
};

editorCaller.prototype.generateEditor = function(){
	var $this = this;
	nhn.husky.EZCreator.createInIFrame({
		oAppRef: window.oEditors,
		elPlaceHolder: $this.elPlaceHolder,
		sSkinURI: "/common/js/editor/SmartEditor2Skin.html",	
		htParams : {
			bUseToolbar : true,				// 툴바 사용 여부 (true:사용/ false:사용하지 않음)
			bUseVerticalResizer : true,		// 입력창 크기 조절바 사용 여부 (true:사용/ false:사용하지 않음)
			bUseModeChanger : true,			// 모드 탭(Editor | HTML | TEXT) 사용 여부 (true:사용/ false:사용하지 않음)
			//aAdditionalFontList : aAdditionalFontSet,		// 추가 글꼴 목록
			fOnBeforeUnload : function(){
				alert("완료!");
			}
		}, //boolean
		fOnAppLoad : function(){
			//예제 코드
			window.oEditors.getById[$this.elPlaceHolder].exec("PASTE_HTML", $this.serverContents);
		},
		fCreator: "createSEditor2"
	});
};

editorCaller.prototype.pasteHTML = function(contents){
	window.oEditors.getById[this.elPlaceHolder].exec("PASTE_HTML", [contents]);
};

editorCaller.prototype.getEditorContentHTML = function(){
	return window.oEditors.getById[this.elPlaceHolder].getIR();
};

var editor = new editorCaller(option);
editor.init();*/
/*
var oEditors = [];

// 추가 글꼴 목록
//var aAdditionalFontSet = [["MS UI Gothic", "MS UI Gothic"], ["Comic Sans MS", "Comic Sans MS"],["TEST","TEST"]];

nhn.husky.EZCreator.createInIFrame({
	oAppRef: oEditors,
	elPlaceHolder: "ir1",
	sSkinURI: "/common/js/editor/SmartEditor2Skin.html",	
	htParams : {
		bUseToolbar : true,				// 툴바 사용 여부 (true:사용/ false:사용하지 않음)
		bUseVerticalResizer : true,		// 입력창 크기 조절바 사용 여부 (true:사용/ false:사용하지 않음)
		bUseModeChanger : true,			// 모드 탭(Editor | HTML | TEXT) 사용 여부 (true:사용/ false:사용하지 않음)
		//aAdditionalFontList : aAdditionalFontSet,		// 추가 글꼴 목록
		fOnBeforeUnload : function(){
			//alert("완료!");
		}
	}, //boolean
	fOnAppLoad : function(){
		//예제 코드
		//oEditors.getById["ir1"].exec("PASTE_HTML", ["로딩이 완료된 후에 본문에 삽입되는 text입니다."]);
	},
	fCreator: "createSEditor2"
});

function pasteHTML() {
	var sHTML = "<span style='color:#FF0000;'>이미지도 같은 방식으로 삽입합니다.<\/span>";
	oEditors.getById["ir2"].exec("PASTE_HTML", [sHTML]);
}

function showHTML() {
	var sHTML = oEditors.getById["ir1"].getIR();
	alert(sHTML);
}
	
function submitContents(elClickedObj) {
	oEditors.getById["ir1"].exec("UPDATE_CONTENTS_FIELD", []);	// 에디터의 내용이 textarea에 적용됩니다.
	return;
	// 에디터의 내용에 대한 값 검증은 이곳에서 document.getElementById("ir1").value를 이용해서 처리하면 됩니다.
	
	try {
		elClickedObj.form.submit();
	} catch(e) {}
}

function setDefaultFont() {
	var sDefaultFont = '궁서';
	var nFontSize = 24;
	oEditors.getById["ir1"].setDefaultFont(sDefaultFont, nFontSize);
}*/
</script>
<div id="log"></div>
</body>
</html>